package com.otc.controller;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.Map;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.otc.model.Movies;
import com.otc.model.OpinionThatCounts;

@Controller
public class MovieController1 {

	@RequestMapping("/Movies")
	public ModelAndView helloWorld() {

		OpinionThatCounts otc = new OpinionThatCounts();
		ArrayList<Movies> movieData = otc.retrieveBollywoodMovies();
		ArrayList<String> userName = otc.retrieveUserName();
		
		ModelAndView mav = new ModelAndView("Movies/Movies");
		Map<String, Object> modelMap = new LinkedHashMap<String, Object>();
		modelMap.put("message", movieData);
		modelMap.put("username", userName);
		mav.addAllObjects(modelMap);
		return mav;
	}
	
	@RequestMapping("/index")
	public ModelAndView indexDetails() {

		OpinionThatCounts otc = new OpinionThatCounts();
		ArrayList<Movies> movieData = otc.retrieveBollywoodMovies();
		
		ModelAndView mav1 = new ModelAndView("index");
		Map<String, Object> modelMap = new LinkedHashMap<String, Object>();
		modelMap.put("message1", movieData);
		modelMap.put("username1", "saurav");	
		mav1.addAllObjects(modelMap);
		return mav1;
	}

}